<style>
    #show_toolbar span {
        color: green;font-weight: bold;font-size: 22px;
    }
</style>
<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-4">
                <input type="text" name="datetime" id="datetime" placeholder="start_time _ end_time" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>Search</button>
            </div>
        </div>
        <div class="layui-inline" style="padding-left:20px;">
            <button class="layui-btn layui-btn-sm" lay-submit lay-filter="user_data_update">Update Data</button>
            <span style="font-size: 20px;padding-left: 20px;">
                Refresh Time : <span id="up_time" style="color: #FF5722">{$time}</span>
            </span>
        </div>
    </div>
    <div class="layui-form-item" style="height: 40px;">
        <div style="font-size: 18px;" id="show_toolbar">
            Available Balance : $ <span id="available_balance" >Please Refresh(Update Data)</span>
        </div>
    </div>
</form>

<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>
<script>
    layui.use(['form', 'layedit', 'laydate', 'table'], function () {
        var laydate = layui.laydate;

        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });
        layui.table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            totalRow: true,
            method: 'post',
            url: "{:url('indexDataOther')}",
            id: 'balanceTable',
            cols: [[
                { type: 'numbers'},
                { field: 'ctime', align: 'center', title: 'create time' ,width:200,
                    templet: function (d) {
                        return layui.util.toDateString(d.ctime * 1000, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                { field: 'static_amount', title: 'StaticAmount', align:"right",
                    style:'font-weight:bold'},
                { field: 'diff_amount', title: 'DiffAmount', align:"right",
                    style:'font-weight:bold'},
                { field: 'reversal_amount', title: 'ReversalAmount', align:"right",
                    style:'font-weight:bold'},
                { field: 'reversal_expire_amount', title: 'ReversalExpireAmount', align:"right",
                    style:'font-weight:bold'},
                { field: 'total_deposit', title: 'TotalDeposit', align:"right",
                    style:'font-weight:bold'},
                { field: 'sum_amount', title: 'SumAmount', align:"right",
                    style:'font-weight:bold'},
                { field: 'tran_amount', title: 'TranAmount', align:"right",
                    style:'font-weight:bold'},
                { field: 'available_balance', title: 'AvailableBalance', align:"right",
                    style:'font-weight:bold'},
            ]],
            page: true,
            limit: 20,
            limits: [20, 50, 100],
        });
        layui.form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //余额编辑
        $(document).on('click', '.SearchDetail', function () {
            var id = $(this).attr('data-id');
            JsGet("{:url('showHistory')}?id="+id, function(e){
                if(e.status == 1){
                    layer.open({
                        type: 1,
                        title: 'Log Detail',
                        area: ['1000px', '600px'], //宽高
                        content: e.datas,
                        btn:['Close']
                    });
                }else{
                    layer.msg(e.msg);
                }
            });
        });
        layui.form.on('submit(user_data_update)', function () {
            var loading =layer.load(1, {shade: [0.1,'#fff']});
            JsPost("{:url('user/userAvailableBalance')}",'', function(res){
                layer.close(loading);
                if(res.code >0){
                    $('#up_time').text(res.data.time);
                    $('#available_balance').text(res.data.available_balance);
                }else{
                    layer.msg(res.msg , {time:1500 , icon:2});
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>